package com.design_pattern.command;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Command> commands = new ArrayList<>();
        StringBuilder stringBuilder = new StringBuilder();
        commands.add(new CommandImpl(stringBuilder));
        commands.add(new CommandImpl(stringBuilder));
        commands.add(new CommandImpl(stringBuilder));
        for (Command command : commands) {
            command.doIt();
        }
        System.out.println(stringBuilder);
        commands.get(commands.size() - 1).undo();
        System.out.println(stringBuilder);
        commands.get(commands.size() - 1).undo();
        System.out.println(stringBuilder);
    }
}
